//
//  ASTextHeadView.m
//  AvatarShow
//
//  Created by xunruiIOS on 2021/4/29.
//

#import "ASTextHeadView.h"

@implementation ASTextHeadView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self.contentView addSubview:self.searchView];
        [self.contentView addSubview:self.tagView];
        [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.mas_equalTo(0);
            make.height.mas_equalTo(58);
        }];
        @weakify(self);
        [self.tagView mas_makeConstraints:^(MASConstraintMaker *make) {
            @strongify(self);
            make.left.right.mas_equalTo(0);
            make.top.mas_equalTo(self.searchView.mas_bottom);
            make.height.mas_equalTo(45);
        }];
    }
    return self;
}

//- (instancetype)initWithFrame:(CGRect)frame{
//    self = [super initWithFrame:frame];
//    if (self) {
//        [self addSubview:self.searchView];
//        [self addSubview:self.tagView];
//        [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.right.top.mas_equalTo(0);
//            make.height.mas_equalTo(58);
//        }];
//        @weakify(self);
//        [self.tagView mas_makeConstraints:^(MASConstraintMaker *make) {
//            @strongify(self);
//            make.left.right.mas_equalTo(0);
//            make.top.mas_equalTo(self.searchView.mas_bottom);
//            make.height.mas_equalTo(45);
//        }];
//    }
//    return self;
//}

- (ASAvatarGroupSearchView *)searchView{
    if (!_searchView) {
        _searchView = [[ASAvatarGroupSearchView alloc]initWithFrame:CGRectZero];
    }
    return _searchView;
}

- (ASTextHeadTagView *)tagView{
    if (!_tagView) {
        _tagView = [[ASTextHeadTagView alloc]initWithFrame:CGRectZero];
    }
    return _tagView;
}

+ (CGFloat)headHeightIfTag:(NSString *)searchContent{
    if ([searchContent isNotBlank]) {
        return 58;
    }
    return 103;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
